package com.weishu.installment.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.weishu.installment.domain.CfContract;
import com.weishu.installment.domain.SfContractEntity;
import com.weishu.installment.service.CfContractService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("contract")
public class CfController {
    @Resource
    CfContractService service;

    @PostMapping("list")
    @RequiresPermissions("contract:contract:list")
    public Map list(@RequestBody CfContract ment){
        Page page = new Page(ment.getPageNum(),ment.getPageSize());
        QueryWrapper<CfContract> wrapper = new QueryWrapper<>();
        if (ment.getTenantName()!=null&&!ment.getTenantName().equals("")){
            wrapper.eq("tenant_name",ment.getTenantName());
        }
        Page page1 = service.page(page, wrapper);
        Map map = new HashMap();
        map.put("total",page1.getTotal());
        map.put("list",page1.getRecords());
        return map;
    }
}
